#ifndef __WIZ_BNF_PARSER_KLEENESTAR_HPP__SHANHAOBO_19800429__
#define __WIZ_BNF_PARSER_KLEENESTAR_HPP__SHANHAOBO_19800429__

#include "./WizBNFParserUnary.hpp"

namespace Wiz
{
    namespace BNF
    {
        namespace Parser
        {
            namespace KleeneStar
            {
                template <class SubjectT>
                struct Type : public ::Wiz::BNF::Parser::Unary::Type<SubjectT, ::Wiz::BNF::Parser::Type<Type<SubjectT>>>
                {
                    typedef Type<SubjectT>                                                                      tThis;
                    typedef ::Wiz::BNF::Parser::Unary::Type<SubjectT, ::Wiz::BNF::Parser::Type<Type<SubjectT>>> tSuper;

                    Type(const SubjectT& Sbjct) : tSuper(Sbjct)
                    {}

                    template <class ScannerT>
                    typename ::Wiz::BNF::Parser::Result<tThis, ScannerT>::tType
                    ParseImpl(ScannerT const& Scan) const
                    {
                        typedef ::Wiz::BNF::Parser::Result<tThis, ScannerT>::tType tResult;

                        tResult Rslt = Scan.EmptyMatch();

                        while (::Wiz::Bool::True)
                        {
                            tResult RsltTemp = this->Subject().Parse(Scan);
                            if (RsltTemp.IsValid())
                            {
                                Scan.ConcatMatch(Rslt, RsltTemp);
                            }
                            else
                            {
                                return Rslt;
                            }
                        }
                    }
                }; /// end of struct Type
            } /// end of namespace KleeneStar
        } /// end of namespace Parser
    } /// end of namespace BNF
} /// end of namespace Wiz

#endif /*__WIZ_BNF_PARSER_KLEENESTAR_HPP__SHANHAOBO_19800429__*/
